<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>列表渲染</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">

        <!--遍历数组是用的最多的-->
        <h2>列表</h2>
        <ul>
            <!--每个对象需要一个标识-->
            <!-- <li v-for="per in person" :key="per.id">
                {{per.name}}-{{per.age}}
            </li> -->
            <!--index也可以作为key值-->
            <!--in可以用of代替-->
            <li v-for="(per,index) in person" :key="index">
                {{per.name}}-{{per.age}}
            </li>
        </ul>


        <h2>汽车信息</h2>
        <ul>
            <li v-for="(value,key) of car" :key="key">
                {{key}}-{{value}}
            </li>
        </ul>


        <h2>遍历字符串</h2>
        <ul>
            <li v-for="(char,index) of str" :key="index">
                {{index}}-{{char}}
            </li>
        </ul>


        <h2>遍历指定次数</h2>
        <ul>
            <li v-for="(number,index) of 5" :key="index">
                {{index}}-{{number}}
            </li>
        </ul>
    </div>
</body>

<script>
    new Vue({
        el:'#root',
        data:{
          person:[
            {id:'001',name:'A',age:18},
            {id:'002',name:'B',age:19},
            {id:'003',name:'C',age:20}
          ],
          car:{
            name:'奥体',
            price:'70万',
            color:'黑色'
          },
          str:'hello'
        }
    })
</script>

</html>